﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TPLOAWebService.Models
{
    public class MCRepository : IMCRepository
    {
        public IEnumerable<MC> GetAll()
        {
            return TPLOADBManager.GetAllMC().Cast<MC>();
        }

        public MC Get(int id)
        {
            return TPLOADBManager.GetMCByID(id);
        }

        public MC Add(MC item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (TPLOADBManager.InsertMC(item) == 0)
            {
                return null;
            }
            else
            {
                return item;
            }
        }

        public void Remove(int id)
        {
            TPLOADBManager.DeleteMC(id);
        }

        public bool Update(MC item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (TPLOADBManager.UpdateMC(item) == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}